﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Game : MonoBehaviour,SocketListener
{


    public void StartGameSocket()
    {
        StartCoroutine(DoStartGameSocket());
    }
    private IEnumerator DoStartGameSocket()
    {
        SocketManager socketManager = SocketManager.Instance;
        yield return socketManager;

        socketManager.socketListener = this;
        SocketReady();
    }

    /* ------ Button Click ------ */
    public virtual void OnClickBack()
    {
        SocketConnectInfo.Instance.roomFixseat = true; 
        SocketManager.Instance.socketListener = null;
        SocketManager.Instance.Disconnect("Exit from the game.");
       
    }

    /* ------ Socket Sender ------ */
    public void SendPackage(string message)
    {
        SocketManager socketManager = SocketManager.Instance;
        socketManager.SendPackage(message);
    }
    public void SendPackageWithJson(JSONObject messageObj)
    {
        SocketManager socketManager = SocketManager.Instance;
        socketManager.SendPackageWithJson(messageObj);
    }

    /* ------ Socket Listener ------ */
    public virtual void SocketReady()
    {
        
    }
    public virtual void SocketReceiveMessage(byte[] message)
    {
      
    }

    public virtual void SocketDisconnect(string disconnectInfo)
    {
      
    }

    public void OnSocketDisconnect(string disconnectInfo)
    {
    }



}
